package com.wc.alorithm_blue_bridge._思维.Q3792;

import java.util.*;
/**
 * @Author congege
 * @Description
 * 小蓝的礼物
 * https://www.lanqiao.cn/problems/3792/learning/?page=1&first_category_id=1
 * @Date Created in 2023/11/23-21:51
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] array = new int[n];
        int ans = -1;
        for(int i = 0; i < n; i++){
            array[i] = scan.nextInt();
        }

        Arrays.sort(array);
        for(int i = 0; i < n; i++){
            if(k >= array[i]){
                k = k - array[i];
            } else {
                ans = i;
                if (k >= (array[i] + 1) / 2){
                    ans++;
                }
                break;
            }
        }
        if(ans == -1){
            ans = n;
        }

        System.out.println(ans);
        scan.close();
    }
}
